package hibernate.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NamedQueries;
import org.hibernate.annotations.NamedQuery;
import org.hibernate.annotations.Parameter;

@SuppressWarnings("serial")
@Entity
@Table(name = "musteri", catalog = "emmy", uniqueConstraints = {
		@UniqueConstraint(columnNames = "adresid"),
		@UniqueConstraint(columnNames = "tcKimlik") })
@NamedQueries({  // şimdilik bu query'lere gerek yok ihtiyaç olursa diye hazırlandı...
@NamedQuery(name = "findMusteritcKimlik", 	query = "from Musteri where tcKimlik = :mTcKimlik"),
@NamedQuery(name = "findMusteriAd", 		query = "from Musteri where ad = :mAd"),
@NamedQuery(name = "findMusteriSoyad", 		query = "from Musteri where soyad = :mSoyad"),
@NamedQuery(name = "findMusteriTel1", 		query = "from Musteri where tel1 = :mTel1"),
@NamedQuery(name = "findMusteriTel2", 		query = "from Musteri where tel2 = :mTel2"),
@NamedQuery(name = "findMusteriFax", 		query = "from Musteri where fax = :mFax"),
@NamedQuery(name = "findMusteriEmail", 		query = "from Musteri where email = :mEmail"),
@NamedQuery(name = "findMusteriKisiWebAdd", query = "from Musteri where kisiselWebAdd like :mKisiWeb"),
@NamedQuery(name = "findMusteriDogumTarihi",query = "from Musteri where dogumTarihi = :mDogumTrh")
})
public class Musteri implements java.io.Serializable {

	private long kullaniciid;
	private Adres adres;
	private Kullanici kullanici;
	private long tcKimlik;
	private String ad;
	private String soyad;
	private long tel1;
	private Long tel2;
	private Long fax;
	private String email;
	private String kisiselWebAdd;
	private String dogumTarihi;
	private Set<Musteriaygitlari> musteriaygitlaris = new HashSet<Musteriaygitlari>(0);
	private Set<Yorumlar> yorumlars = new HashSet<Yorumlar>(0);
	private Set<Aygitihbar> aygitihbars = new HashSet<Aygitihbar>(0);

	public Musteri() {
	}

	public Musteri(Adres adres, Kullanici kullanici, long tcKimlik, String ad,
			String soyad, long tel1, String email, String dogumTarihi) {
		this.adres = adres;
		this.kullanici = kullanici;
		this.tcKimlik = tcKimlik;
		this.ad = ad;
		this.soyad = soyad;
		this.tel1 = tel1;
		this.email = email;
		this.dogumTarihi = dogumTarihi;
	}

	public Musteri(Adres adres, Kullanici kullanici, long tcKimlik, String ad,
			String soyad, long tel1, Long tel2, Long fax, String email,
			String kisiselWebAdd, String dogumTarihi,
			Set<Musteriaygitlari> musteriaygitlaris, Set<Yorumlar> yorumlars,
			Set<Aygitihbar> aygitihbars) {
		this.adres = adres;
		this.kullanici = kullanici;
		this.tcKimlik = tcKimlik;
		this.ad = ad;
		this.soyad = soyad;
		this.tel1 = tel1;
		this.tel2 = tel2;
		this.fax = fax;
		this.email = email;
		this.kisiselWebAdd = kisiselWebAdd;
		this.dogumTarihi = dogumTarihi;
		this.musteriaygitlaris = musteriaygitlaris;
		this.yorumlars = yorumlars;
		this.aygitihbars = aygitihbars;
	}

	@GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name = "property", value = "kullanici"))
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "kullaniciid", unique = true, nullable = false)
	public long getKullaniciid() {
		return this.kullaniciid;
	}

	public void setKullaniciid(long kullaniciid) {
		this.kullaniciid = kullaniciid;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	@JoinColumn(name = "adresid", unique = true, nullable = false)
	public Adres getAdres() {
		return this.adres;
	}

	public void setAdres(Adres adres) {
		this.adres = adres;
	}

	@OneToOne(fetch = FetchType.EAGER, cascade= CascadeType.ALL)	
	@PrimaryKeyJoinColumn
	public Kullanici getKullanici() {
		return this.kullanici;
	}

	public void setKullanici(Kullanici kullanici) {
		this.kullanici = kullanici;
	}

	@Column(name = "tcKimlik", unique = true, nullable = false)
	public long getTcKimlik() {
		return this.tcKimlik;
	}

	public void setTcKimlik(long tcKimlik) {
		this.tcKimlik = tcKimlik;
	}

	@Column(name = "ad", nullable = false, length = 20)
	public String getAd() {
		return this.ad;
	}

	public void setAd(String ad) {
		this.ad = ad;
	}

	@Column(name = "soyad", nullable = false, length = 20)
	public String getSoyad() {
		return this.soyad;
	}

	public void setSoyad(String soyad) {
		this.soyad = soyad;
	}

	@Column(name = "tel1", nullable = false)
	public long getTel1() {
		return this.tel1;
	}

	public void setTel1(long tel1) {
		this.tel1 = tel1;
	}

	@Column(name = "tel2")
	public Long getTel2() {
		return this.tel2;
	}

	public void setTel2(Long tel2) {
		this.tel2 = tel2;
	}

	@Column(name = "fax")
	public Long getFax() {
		return this.fax;
	}

	public void setFax(Long fax) {
		this.fax = fax;
	}

	@Column(name = "email", nullable = false, length = 40)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "kisiselWebAdd", length = 40)
	public String getKisiselWebAdd() {
		return this.kisiselWebAdd;
	}

	public void setKisiselWebAdd(String kisiselWebAdd) {
		this.kisiselWebAdd = kisiselWebAdd;
	}

	@Column(name = "dogumTarihi", nullable = false, length = 10)
	public String getDogumTarihi() {
		return this.dogumTarihi;
	}

	public void setDogumTarihi(String dogumTarihi) {
		this.dogumTarihi = dogumTarihi;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "musteri", cascade = CascadeType.REMOVE)
	public Set<Musteriaygitlari> getMusteriaygitlaris() {
		return this.musteriaygitlaris;
	}

	public void setMusteriaygitlaris(Set<Musteriaygitlari> musteriaygitlaris) {
		this.musteriaygitlaris = musteriaygitlaris;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "musteri", cascade = CascadeType.REMOVE)
	public Set<Yorumlar> getYorumlars() {
		return this.yorumlars;
	}

	public void setYorumlars(Set<Yorumlar> yorumlars) {
		this.yorumlars = yorumlars;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "musteri", cascade = CascadeType.REMOVE)
	public Set<Aygitihbar> getAygitihbars() {
		return this.aygitihbars;
	}

	public void setAygitihbars(Set<Aygitihbar> aygitihbars) {
		this.aygitihbars = aygitihbars;
	}
}